package com.group9.service.impl;

import com.group9.mapper.FruitPicMapper;
import com.group9.pojo.FruitPic;
import com.group9.pojo.FruitPicExample;
import com.group9.service.FruitPicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Lcouncillor on 2020/5/14.
 */
@Service
public class FruitPicServiceImpl implements FruitPicService {

    @Autowired
    FruitPicMapper fruitPicMapper;

    @Override
    public FruitPic selectByFruitIdAndPicType(Integer fruitId, Byte picType) {
        FruitPicExample fruitPicExample = new FruitPicExample();
        FruitPicExample.Criteria criteria = fruitPicExample.createCriteria();
        criteria.andFruitIdEqualTo(fruitId);
        criteria.andPicTypeEqualTo(picType);

        List<FruitPic> fruitPics = fruitPicMapper.selectByExample(fruitPicExample);
        if ( null != fruitPics && !fruitPics.isEmpty()){
            return fruitPics.get(0);
        }
        return null;
    }
}
